package sgfapp.entities;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

public class DataBaseManager {
	
	

	public static final String TABLE_NAME="breadcrumb";

	
	public static final String CN_ID="id";
	public static final String CN_POS="pos";
	public static final String CN_IM="img";
	public static final String CN_DES="descripcion";
	public static final String CREATE_TABLE="CREATE TABLE "+TABLE_NAME+ "("
			+CN_ID+" integer primary key autoincrement,"
			+CN_POS+" text not null,"
			+CN_IM+" text not null,"
			+CN_DES+" text);";
private  BdHelper helper;
private SQLiteDatabase db;

	public DataBaseManager(Context context) {
    	helper=new BdHelper(context);
        db = helper.getWritableDatabase();

	}
	
	
	public long createRecords(String pos, String im, String des){  
		   ContentValues values = new ContentValues();  
		   values.put(CN_POS, pos);  
		   values.put(CN_IM, im);
		   values.put(CN_DES, des);  
		     
		   return db.insert(TABLE_NAME, null, values);  
		}  
	
	public Cursor selectRecords() {
		   String[] cols = new String[] {CN_POS, CN_IM,CN_DES};  
		   Cursor mCursor = db.query(true, CN_DES,cols,null  
		            , null, null, null, null, null);  
		   if (mCursor != null) {  
		     mCursor.moveToFirst();  
		   }  
		   return mCursor; // iterate to get each value.
		}
	
}
